<?xml version='1.0'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

  <head>

    <title>Logging</title>

    <link href="../css/styles.css" rel="stylesheet" type="text/css"/>
  </head>

  <body>

    <h1>Overview</h1>

    <p>SoapTrace.Net can be configured to log a matched soap request 
    and response pair to an xml file, by default logging is disabled.  
    The name of the file will be based on the date and time the soap 
    message was received - "yyyy-MM-dd HH_mm_ss_fff.xml" - which 
    hopefully should be unique.</p>

    <h1>Configuring</h1>

    <p>To configure the logging, open up the Tools-&gt;Options dialog 
    and click the "Logging" tab.  Here you can configure the logging 
    folder and whether logging is enabled.</p>

    <p><img src="img/loggingOptions.png"/></p>

    <p>The default folder used is "C:\Documents and 
    Settings\[UserName]\Local Settings\Application 
    Data\SoapTrace.Net\Log".</p>

    <h1>Log File Format</h1>

    <p>Each log file contains a matched soap request and response.</p>

    <pre>&lt;SoapMessage&gt; 
  &lt;Time&gt;2005-02-23 20:01:38.05&lt;/Time&gt; 
  &lt;Filter&gt; 
    &lt;Server&gt;www.codeproject.com&lt;/Server&gt; 
    &lt;Port&gt;80&lt;/Port&gt; 
  &lt;/Filter&gt; 
  &lt;Source&gt;192.168.1.4:3196&lt;/Source&gt; 
  &lt;Request&gt; 
    &lt;Time&gt;2005-02-23 20:01:38.05&lt;/Time&gt; 
    &lt;Header&gt;&lt;![CDATA[POST /webservices/latest.asmx HTTP/1.1 
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 1.1.4322.573) 
Content-Type: text/xml; charset=utf-8 
SOAPAction: "http://codeproject.com/webservices/GetMaxCommentListLength" 
Content-Length: 317 
Expect: 100-continue 
Host: www.codeproject.com 
 
]]&gt;&lt;/Header&gt; 
    &lt;Message&gt;&lt;![CDATA[&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;soap:Body&gt;&lt;GetMaxCommentListLength xmlns="http://codeproject.com/webservices/" /&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;]]&gt;&lt;/Message&gt; 
  &lt;/Request&gt; 
  &lt;Response&gt; 
    &lt;Time&gt;2005-02-23 20:01:38.71&lt;/Time&gt; 
    &lt;Header&gt;&lt;![CDATA[HTTP/1.1 200 OK 
Server: Microsoft-IIS/5.0 
Date: Wed, 23 Feb 2005 19:47:38 GMT 
X-Powered-By: ASP.NET 
X-AspNet-Version: 1.1.4322 
Cache-Control: no-cache 
Pragma: no-cache 
Expires: -1 
Content-Type: text/xml; charset=utf-8 
Content-Length: 422 
 
]]&gt;&lt;/Header&gt; 
    &lt;Message&gt;&lt;![CDATA[&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;soap:Body&gt;&lt;GetMaxCommentListLengthResponse xmlns="http://codeproject.com/webservices/"&gt;&lt;GetMaxCommentListLengthResult&gt;10&lt;/GetMaxCommentListLengthResult&gt;&lt;/GetMaxCommentListLengthResponse&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;]]&gt;&lt;/Message&gt; 
  &lt;/Response&gt; 
&lt;/SoapMessage&gt;</pre>
    <h1>Custom Logger</h1>

    <p>If the logging file format is not good enough for your needs 
    then the logger can be replaced by your own custom one.  The custom 
    logger will need to implement the 
    SoapTrace.Core.Diagnostics.ISoapMessageLogger interface.</p>

    <pre> /// &lt;summary&gt; 
 /// Interface for all soap message loggers. 
 /// &lt;/summary&gt; 
 public interface ISoapMessageLogger 
 { 
  /// &lt;summary&gt; 
  /// Called when a soap request and response have arrived. 
  /// &lt;/summary&gt; 
  /// &lt;param name="serverAddressFilter"&gt;The remote server's IP address 
  /// or host name used when filtering.&lt;/param&gt; 
  /// &lt;param name="serverPortFilter"&gt;The remote server's port 
  /// used when filtering. 
  /// &lt;/param&gt; 
  /// &lt;param name="requestAndResponse"&gt;The soap request and  
  /// response.&lt;/param&gt; 
  void Log( string serverAddressFilter,  
   int serverPortFilter,  
   SoapRequestAndResponse requestAndResponse ); 
   
  /// &lt;summary&gt; 
  /// Turns logging on or off. 
  /// &lt;/summary&gt; 
  bool Enabled { get; set; } 
   
  /// &lt;summary&gt; 
  /// Sets the logging folder. 
  /// &lt;/summary&gt; 
  string Folder { get; set; } </pre>
    <p>To make SoapTrace.Net use your custom logger place your assembly 
    dll into the SoapTrace/bin folder, edit the config file found in 
    "C:\Documents and Settings\[UserName]\Local Settings\Application 
    Data\SoapTrace.Net\SoapTrace.Net\[Version]\SoapTrace.exe.user.config" 
    and alter the SoapMessageLogger xml element so it refers to your 
    custom logger type:</p>

    <pre>  &lt;SoapMessageLogger enabled="true" type="SoapTrace.Core.Diagnostics.SoapMessageLogger, SoapTrace.Core"&gt; 
    &lt;Folder&gt;C:\temp\test&lt;/Folder&gt; 
  &lt;/SoapMessageLogger&gt; </pre>
    <p>There is a corresponding xml element in the SoapTrace.exe.config 
    file which you may want to change so all users will use your custom 
    logger by default.</p>

    <p />

    <p />

  </body>

</html>

